﻿//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;
using Microsoft.Practices.ObjectBuilder2;

namespace EntLibContrib.Query.Configuration
{
	/// <summary>
	/// This type supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
	/// Represents the process to build an <see cref="ParameterSet"/> described by a <see cref="ParameterSetData"/> configuration object.
	/// </summary>
	/// <remarks>This type is linked to the <see cref="ParameterSetData"/> type and it is used by the <see cref="ParameterSetCustomFactory"/> 
	/// to build the specific <see cref="IParameterSet"/> object represented by the configuration object.
	/// </remarks>	
	public class ParameterSetAssembler : IAssembler<IParameterSet, ParameterSetData>
	{
		#region Public Methods
		/// <summary>
		/// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
		/// Builds a <see cref="ParameterSet"/> based on an instance of <see cref="ParameterSetData"/>.
		/// </summary>
		/// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
		/// <param name="objectConfiguration">The configuration object that describes the object to build. Must be an instance of <see cref="ParameterSetData"/>.</param>
		/// <param name="configurationSource">The source for configuration objects.</param>
		/// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
		/// <returns>
		/// A fully initialized instance of <see cref="ParameterSet"/>.
		/// </returns>
		/// <seealso cref="ParameterSetCustomFactory"/>
		public IParameterSet Assemble(IBuilderContext context, ParameterSetData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
		{
			IParameterSet createdObject = new ParameterSet(QueryAssemblerHelper.CreateParameterDictionary(objectConfiguration.Parameters, context, configurationSource, reflectionCache));

			return createdObject;
		}
		#endregion
	}
}
